package fangzhiyi.test;

/**
 * @author fangzhiyi
 * @version 1.0
 * @date 2025/3/18 16:01
 * @description
 */
public class WorkPractice {

    //1.	请定义一个交通工具(Vehicle)的类其中有:  属性： 速度(speed)、 体积(size)等，
    // 方法：移动(move())、设置速度(setSpeed(int speed))、加速 speedUp()、减速 speedDown()等。
    // 最后在测试类 Vehicle 中的 main()中实例化一个交通工具对象并通过方法给它初始化 speed,size 的值并且通过打印出来。
    // 另外调用加速、减速的方法对速度进行改变。
    public static void main1(String[] args) {
        Vehicle vehicle = new Vehicle();
        vehicle.setSpeed(60);
        vehicle.setSize(20);

        System.out.println("初始速度: " + vehicle.getSpeed());
        System.out.println("初始体积: " + vehicle.getSize());

        vehicle.speedUp();
        System.out.println("加速后的速度: " + vehicle.getSpeed());

        vehicle.speedDown();
        System.out.println("减速后的速度: " + vehicle.getSpeed());
    }

    public static void main2(String[] args) {
        Person person = new Person("方知意",18);
        System.out.println("姓名:"+person.getName());
        System.out.println("姓名:"+person.getAge());
        person.display();
    }


    public static void main3(String[] args) {
        Calculaion calculaion = new Calculaion(12,2);
       double add= calculaion.add();
       double sub= calculaion.sub();
       double times= calculaion.times();
       double div= calculaion.div();
        System.out.println("加的结果是"+add+"减的结果是"+sub+"乘的结果是"+times+"除的结果是"+div);
    }

    public static void main4(String[] args) {
        Student student = new Student("001","方知意","男",18,90);
        System.out.println("学号是:  " + student.getsNO());
        System.out.println("姓名是： " + student.getsName());
        System.out.println("性别是:  " + student.getsSex());
        System.out.println("年龄是:  " + student.getsAge());
        System.out.println("成绩是:  " + student.getsJava());

        Student[] students = new Student[]{new Student("001", "方知意", "男", 18, 90),
                new Student("002", "柳婉莹", "女", 18, 90),
                new Student("010", "方", "男", 18, 80),
                new Student("011", "知", "男", 18, 54),
                new Student("012", "意", "男", 18, 32)
        };
        for (Student student1 : students) {
           student1.studentShow();
        }
        double sum = 0;
        for (int i = 0; i < students.length; i++) {
            students[i].getsJava();
            sum  = sum + students[i].getsJava();
        }
        double avg = sum / students.length;
        System.out.println(sum);
        System.out.println(avg);

        double max = students[0].getsJava();
        double min = students[0].getsJava();
        for (int i = 0; i < students.length; i++) {
          double stu=  students[i].getsJava();
          if (max<stu){
              max = stu;
          }
          if (min>stu){
              min = stu;
          }
        }
        System.out.println("Java成绩的最大值为:" + max);
        System.out.println("Java成绩的最小值为:" + min);
    }
    }


